// pages/components/filterBox/filterBox.js
// import filter from './filterBillServer';
var regeneratorRuntime = require("../../../lib/js/runtime-module.js")
const dataObj = require("./makeData.js");
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    // heads:{
    //   type:Array,
    //   value:'heads'
    // },
    housesList: {
      type: Array,
      value: 'housesList'
    },
    typeList:{
      type: Array,
      value: 'typeList'
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    // heads: this.properties.heads,
    bg: false,
    selectIndex: -1,
    heads: ["全部楼盘", "全部类型"],
    contentIndex: -1
  },

  /**
   * 组件的方法列表
   */
  methods: {
    /**
     * 生命周期函数--监听页面加载
     */
    //选择楼盘
    selectHouse(e){
      console.log(e)
      let selectHouse = e.currentTarget.dataset.name;
      let heads = this.data.heads
      heads[0] = selectHouse
      this.triggerEvent('selectChange', heads);   //向外传递数据
      this.setData({
        heads: heads,
        selectIndex: -1,
      });
    },
    //选择类型
    selectType(e){
      let selectHouse = e.currentTarget.dataset.type;
      let heads = this.data.heads
      heads[1] = selectHouse
      this.triggerEvent('selectChange', heads);
      this.setData({
        heads: heads,
        selectIndex: -1
      });
    },
    // 标题切换交互绑定
    headerSelect(e) {
      const index = e.target.dataset.index;
      let headerTitle = this.data.headerTitle;
      let select = headerTitle[index].select;
      if (select) {
        headerTitle.forEach(ele => {
          ele.select = false;
        });
        this.setData({ contentShow: null, isMaskShow: true, headerTitle })
      } else {
        headerTitle.forEach(ele => {
          ele.select = false;
        });
        headerTitle[index].select = true;
        this.setData({
          contentShow: index,
          headerTitle,
          isMaskShow: false,
        });
      }
    },
   
    // 展示提示
    showTip(title) {
      wx.showToast({
        title: title,
        icon: "none"
      })
    },
    // 选中导航
    selectNav(e) {
      let index = e.target.dataset.index;
      let selectIndex = this.data.selectIndex;
      console.log(selectIndex)
      if (selectIndex == index) {
        // 要折叠菜单
        this.setData({
          selectIndex: -1,
          // tempSelect: tempSelect
        });
      } else {
        // 要展开菜单
        this.setData({
          selectIndex: index,
          // tempSelect: tempSelect
        });
      }
      // 选择导航 会影响缓存同步问题，和点击蒙版同一个道理,需要重置缓存
    },
    hideMask() {
      this.setData({selectIndex: -1});
    }
  }
})